package com.example.health_hjk;

import androidx.appcompat.app.AppCompatActivity;

import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoPlayerActivity extends AppCompatActivity {

    private VideoView videoView;
    ImageView iv_back;
    MediaController controller;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_player);

        iv_back = findViewById(R.id.videoplayer_iv_back);
        videoView = (VideoView)findViewById(R.id.videoplayer_vV);
        //设置返回
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //播放视频
        String url = "android.resource://" + getPackageName() + "/" + R.raw.video;
        Log.i("--path--",url);
        Uri uri = Uri.parse(url);
        videoView.setVideoURI(uri);
        controller = new MediaController(this);
        videoView.setMediaController(controller);
        videoView.start();
    }
}